<template>

	<div class="mt30">
		<!--form表单-->
		<el-form size="small" ref="form" :model="form" label-width="200px">
			<el-form-item label="提现方式">
				<el-checkbox-group v-model="form.pay_type">
					<el-checkbox v-for="(item, index) in list" :label="item.id"
						:key="index">{{ item.name }}</el-checkbox>
				</el-checkbox-group>
				<div class="tips">
					注：如使用微信支付，则需申请微信支付商家转账到零钱功能
				</div>
			</el-form-item>
			<el-form-item label="微信转账场景 " prop="scene_id">
				<el-input placeholder="请输入转账场景" v-model="form.scene_id" class="max-w460">
				</el-input>
				<div class="lh18 mt10 gray9">
					<p> 注：应用--＞支付设置--＞微信支付设置里的微信提现方式为商家发起转账时必填</p>
					<p> 注：前往微信支付商户平台> 产品中心 > 运营工具 > 商家转账 > 申请开通 > 新增场景</p>
					<p> 注：添加完后显示ID：1005，将1005填入</p>
				</div>
			</el-form-item>
			<el-form-item label="最低提现额度" prop="min_money" :rules="[{ required: true, message: ' ' }]">
				<el-input v-model="form.min_money" type="number" class="max-w460"></el-input>
			</el-form-item>
			<el-form-item label="佣金结算天数" prop="settle_days" :rules="[{ required: true, message: ' ' }]">
				<el-input v-model="form.settle_days" type="number" class="max-w460"></el-input>
				<div class="tips">
					<p>
						当订单完成n天后，该订单的分销佣金才会结算到分销商余额，如果设置为0天
						则订单完成时就结算
					</p>
					<p class="red">
						注：建议佣金结算天数大于允许发起售后申请天数，如果用户申请退款退货
						则不结算佣金
					</p>
				</div>
			</el-form-item>

			<!--提交-->
			<div class="common-button-wrapper">
				<el-button size="small" type="primary" @click="onSubmit" :loading="loading">提交</el-button>
			</div>
		</el-form>
	</div>
</template>

<script>
	import {
		settlement
	} from "@/api/plus.js";

	export default {
		data() {
			return {
				/*form表单数据*/
				form: {
					pay_type: [10],
				},
				list: [],
				selectlist: [10],
				loading: false,
			};
		},
		props: {
			settingData: Object,
		},
		created() {
			this.form = this.settingData.data.settlement.values;

			this.list = this.settingData.pay_type;
		},

		methods: {
			/*提交表单*/
			onSubmit() {
				let self = this;
				let params = self.form;
				if (params.pay_type.length < 1) {
					ElMessage({
						message: "提现方式至少选择一种！",
						type: "warning",
					});
					return;
				}
				self.$refs.form.validate((valid) => {
					if (valid) {
						self.loading = true;
						settlement({
									form: params,
								},
								true
							)
							.then((data) => {
								self.loading = false;
								ElMessage({
									message: "恭喜你，设置成功",
									type: "success",
								});
							})
							.catch((error) => {
								self.loading = false;
							});
					}
				});
			},
		},
	};
</script>

<style></style>